package com.neuedu.service.login.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neuedu.bean.EmployeeExt;
import com.neuedu.bean.RestBean;
import com.neuedu.mapper.EmployeeMapper;
import com.neuedu.service.login.LoginService;
@Service
public class LoginServiceImpl implements LoginService {
	@Autowired
    private EmployeeMapper em;
	@Override
	public RestBean<EmployeeExt> login(String username, String password) {
		// TODO Auto-generated method stub
		EmployeeExt result=em.getEmployeeAndDeptByNamePass(username);
		RestBean<EmployeeExt> rb=null;
	    if (result==null) {
			rb=new RestBean<>(501,"用户不存在");
		}else if(!password.equals(result.getPassword())){
            rb=new RestBean<>(501,"密码错误");
		}else{
			result.setPassword(null);
			rb=new RestBean<>(result);
		}
		return rb;

	}

}
